package kael.aiur.dao.mysql;

import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import kael.aiur.database.DBUtil;

public class MySql extends DBUtil {

	@Override
	public List<String> getColumns(ResultSet rs) {
		try {
			Field field = rs.getClass().getSuperclass().getDeclaredField("fields");
			field.setAccessible(true);
			Object[] columns = (Object[])field.get(rs);
			List<String> list = new ArrayList<String>();
			for(Object column : columns){
				list.add(((com.mysql.jdbc.Field)column).getColumnLabel());
			}
			return list;
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	protected String urlConnString() {
		return null;
	}

}
